package datasv.courseQuery_datasv;

import java.util.ArrayList;
import java.util.List;

import data.datafactory.DatabaseOperator;

public class GetAllCouOfSubModel {
	public static void main(String[] args) {
		System.out.println(new GetAllCouOfSubModel().getAllCouOfSubModel("001", "0010102", "001010202"));
	}
	public List<String> getAllCouOfSubModel(String collegeID,String modelID,String subModelID){
		return getInSql(collegeID, modelID, subModelID);
	}
	private List<String> getInSql(String collegeID,String modelID,String subModelID){
		DatabaseOperator op=new DatabaseOperator("college"+collegeID);
		ArrayList<String> list=new ArrayList<String>();
		modelID=subModelID.substring(0,7);
		if(!op.ifDatabaseExist()||!op.ifIDExist("plan_model_list", modelID)||!op.ifFormExist("plan_submodel_list_"+modelID)||!op.ifIDExist("plan_submodel_list_"+modelID, subModelID)){
			return list;
		}
		ArrayList<String> courseList=op.getColumn("course_list", "id");
		for (int i = 0; i < courseList.size(); i++) {
			String m=op.getOneInform(courseList.get(i), "course_list", "submodelID");
			if(m!=null&&m.contains(subModelID)){
				list.add(courseList.get(i));
			}
		}
		return list;
	}
}
